<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<h1></h1>
		<script type="text/javascript">
			const array=["星期天","星期一","星期二","星期三","星期四","星期五","星期六"]
			function display(){
				let date=new Date()
				let year=date.getFullYear()
				let month=date.getMonth()+1
				let day=date.getDate()
				let h=date.getHours()
				let m=date.getMinutes()
				let s=date.getSeconds()
				//1.用if判断
				//2.用switch
				//3.数组
				let week=array[date.getDay()]
				let str=`${year}-${f(month)}-${f(day)} ${f(h)}:${f(m)}:${f(s)} ${week}`
				document.querySelector("h1").innerHTML=str
			}
			function f(s){
				return s>=10?s:"0"+s
			}
			setInterval(display,1000)
		</script>
	</body>
</html>
